﻿/****************************************************************
*   作者：Morain
*   创建时间：2018/2/24 19:09:55
*   描述说明：
*****************************************************************/
using Model;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace Hotfix
{
  [ObjectSystem]
  public class NetInnerComponentSystem : ObjectSystem<NetInnerComponent>, IAwake, IAwake<IPEndPoint>, IUpdate
  {
    public void Awake()
    {
      this.Get().Awake();
    }

    public void Awake(IPEndPoint ipEndPoint)
    {
      this.Get().Awake(ipEndPoint);
    }

    public void Update()
    {
      this.Get().Update();
    }
  }

  public static class NetInnerComponentEx
  {
    public static void Awake(this NetInnerComponent self)
    {
      self.Awake(NetworkProtocol.TCP);
      self.MessagePacker = new MongoPacker();
      self.MessageDispatcher = new InnerMessageDispatcher();
      self.AppType = Game.Scene.GetComponent<StartConfigComponent>().StartConfig.AppType;
    }

    public static void Awake(this NetInnerComponent self, IPEndPoint ipEndPoint)
    {
      self.Awake(NetworkProtocol.TCP, ipEndPoint);
      self.MessagePacker = new MongoPacker();
      self.MessageDispatcher = new InnerMessageDispatcher();
      self.AppType = Game.Scene.GetComponent<StartConfigComponent>().StartConfig.AppType;
    }

    public static void Update(this NetInnerComponent self)
    {
      self.Update();
    }
  }
}
